package xjtu.se.articlecommunity.user.myself.impl;

import com.vdurmont.emoji.EmojiParser;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xjtu.se.articlecommunity.user.home.dto.FeedDto;
import xjtu.se.articlecommunity.user.home.impl.HtmlHandler;
import xjtu.se.articlecommunity.user.myself.dao.SubDao;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class SubService {
    @Resource
    SubDao subDao;
    @Resource
    HtmlHandler htmlHandler;

    public List<FeedDto> returnSubList(String u_id){
        List<FeedDto> list = subDao.getSubList(u_id);
        String htmlStr = "";
        FeedDto dto = null;
        for(int i=0;i<list.size();i++){
            dto = list.get(i);
            dto.setImglist(htmlHandler.HtmlImgHandle(dto.getA_html()));
            dto.setA_html(htmlHandler.HtmlStrHandle(dto.getA_html()));
            String html = EmojiParser.parseToUnicode(dto.getA_html());
            dto.setA_html(html);
            list.set(i,dto);
        }
        return list;
    }
}
